feat(costmap): generic grid projection primitives and typed layer access#13
Merged
Merged
Conversation
Add the substrate needed to feed an arbitrary, caller-owned Grid2d<T> (terrain class, learned traversability, instance ids, ...) into the u8 master costmap as a first-class layer, and to read it back for control — without putting any semantic/learned types in the crate itself. - project_into + MergePolicy (src/costmap/project.rs): the keystone generic projection of Grid2d<T> -> master via a T -> Option<u8> closure. merge_overwrite/merge_max/merge_max_keep_unknown now delegate to it (one codepath; signatures unchanged). - Typed layer access (src/costmap/layered.rs): Layer: Any, LayerId, and add_layer returning a LayerId plus layer/layer_mut downcast accessors, so a layer can own its grid and the caller ingests/queries through &mut LayeredCostmap (no Arc/RwLock). Also makes every layer's internal grid inspectable. - ProjectionLayer<T> (src/layers/projection.rs): an owned-source layer (nav2 CostmapLayer generalized over T + a projection closure). For rolling windows it re-centres the source in update_bounds so producers that fill during update_costs see an already-centred grid. - cost_from_unit/cost_from_range (src/types/cost.rs) and Grid2d::layout_matches (src/grid/grid2d.rs). - examples/learned_traversability.rs: end-to-end rolling-window demo (mock model -> ProjectionLayer -> inflation -> read-back control decision). SimLidarLayer in local_costmap_lidar.rs refactored to compose ProjectionLayer<u8>, validating the abstraction against the existing pattern. Tests cover projection policies, layout_matches, cost conversion, typed access, update_bounds re-centring/extent, the rolling end-to-end path, and projection seeding inflation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the substrate needed to feed an arbitrary, caller-owned Grid2d (terrain class, learned traversability, instance ids, ...) into the u8 master costmap as a first-class layer, and to read it back for control — without putting any semantic/learned types in the crate itself.
Tests cover projection policies, layout_matches, cost conversion, typed access, update_bounds re-centring/extent, the rolling end-to-end path, and projection seeding inflation.